<?php
namespace SimplePhp\Dispatcher;
use SimplePHp\System as sys;
use SimplePhp\Tool as tool;

/**
 * 通过下划线解析成实体类
 */
class PointParseRequest implements IParseRequest {
	use sys\TInject;

	/**
	 * @Inject[di=otss,class=SimplePhp\Tool\FileNameOtss]\
	 * 字符串转换成对象数据的工具类
	 * 比如用.分割的
	 * @var [type]
	 */
	protected $Otss;

	public function parse(Array $data) {
		$parseData = [];
		foreach ($data as $key => $value) {
			//如果是下划线分割
			if (strstr($key, "_") !== false) {
				$OtssData = $this->Otss->setSplit('_')->setStr($key, true)->getObject();
				//[user=>]
				foreach ($OtssData as $key_ => $value_) {
					$parseData[$key_][$value_] = $value;
				}
			} else {
				$parseData[$key] = $value;
			}
		}
		return $parseData;
	}
}